//
//  YQWalletDetailVC.m
//  NewRetail
//
//  Created by yuqin on 2019/6/25.
//  Copyright © 2019 yuqin. All rights reserved.
//

#import "YQWalletDetailVC.h"
#import "YQWalletDetailCell.h"
#import "YQWalletDetailHeadView.h"

@interface YQWalletDetailVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) NSArray *dataArr;
@property (nonatomic, strong) UITableView *walletDetailTB;
@property (nonatomic, strong) YQWalletDetailHeadView *walletHeadView;

@end

@implementation YQWalletDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.txtTitle.text = @"钱包详情";
    self.view.backgroundColor = UIColorFromRGB(0xeeeeee);
    [self setupWalletDetailView];
    self.dataArr = @[@[@"导出Keystore"],@[@"修改密码",@"删除钱包"]];
}

- (void)setupWalletDetailView {
    [self.view addSubview:self.walletHeadView];
    [self.view addSubview:self.walletDetailTB];
    
    
    [self.walletHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(NavigationStatusBarHeight);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, FIT(180)));
    }];

    [self.walletDetailTB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.equalTo(self.walletHeadView.mas_bottom).mas_equalTo(0);
        make.bottom.mas_equalTo(-Botoom_IPhoneX);
        make.width.mas_equalTo(ScreenWidth);
    }];
}

- (UITableView *)walletDetailTB {
    if (!_walletDetailTB) {
        _walletDetailTB = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _walletDetailTB.backgroundColor = UIColorFromRGB(0xeeeeee);
        _walletDetailTB.delegate = self;
        _walletDetailTB.dataSource = self;
        [_walletDetailTB registerNib:[UINib nibWithNibName:YQ_WalletDetailCell bundle:nil] forCellReuseIdentifier:YQ_WalletDetailCell];
    }
    return _walletDetailTB;
}

- (YQWalletDetailHeadView *)walletHeadView {
    if (!_walletHeadView) {
        _walletHeadView = [[YQWalletDetailHeadView alloc] init];
    }
    return  _walletHeadView;
}

#pragma mark - delegate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.dataArr.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.dataArr[section] count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return FIT(10);
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return FIT(54);
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.0001;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YQWalletDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:YQ_WalletDetailCell forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.theTitleLab.text = self.dataArr[indexPath.section][indexPath.row];
    return cell;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}

@end
